import request from '@/utils/request'

// 查询期货日线行情列表
export function listFutureQuote(query) {
    return request({
        url: '/kylin/futureDailyQuote/list',
        method: 'get',
        params: query
    })
}

// 查询期货日线行情详细
export function getFutureQuote(id) {
    return request({
        url: '/kylin/futureDailyQuote/' + id,
        method: 'get'
    })
}

// 新增期货日线行情
export function addFutureQuote(data) {
    return request({
        url: '/kylin/futureDailyQuote',
        method: 'post',
        data: data
    })
}

// 修改期货日线行情
export function updateFutureQuote(data) {
    return request({
        url: '/kylin/futureDailyQuote',
        method: 'put',
        data: data
    })
}

// 删除期货日线行情
export function delFutureQuote(id) {
    return request({
        url: '/kylin/futureDailyQuote/' + id,
        method: 'delete'
    })
}

// 从外部数据源获取期货日线行情
export function fetchFutureQuote(symbol) {
    return request({
        url: '/kylin/futureDailyQuote/fetch/' + symbol,
        method: 'get'
    })
}

/**
 * 获取特定期货代码和天数的收盘价格加权平均价格
 * @param {string} code - 期货代码
 * @param {number} days - 计算天数
 * @returns {Promise}
 */
export function getWeightedAverageClosePrice(code, days) {
  return request({
    url: `/kylin/futureDailyQuote/weightedAverageClosePrice/${code}/${days}`,
    method: 'get'
  });
}